﻿var input_radio_checked = "/Admin/Themes/Images/input_radio_checked.gif";
var input_radio_unchecked = "/Admin/Themes/Images/input_radio_unchecked.gif";

//sender：发送者对象
//ajaxUrl：ajax的Url
//ajaxData：ajax的参数
function SetEnable(sender, ajaxUrl, ajaxData) {
    $.ajax({
        type: "post",
        url: ajaxUrl,
        dataType: "json",
        contentType: "application/json;charset=utf-8",
        data: ajaxData,
        beforeSend: function (XMLHttpRequest) {
            this;
        },
        success: function (json, textStatus) {
            if (json.d == 1) {
                if ($(sender).attr("src") == input_radio_checked) {
                    $(sender).attr("src", input_radio_unchecked);
                } else {
                    $(sender).attr("src", input_radio_checked);
                }
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('设置启用时发生网络错误！');
            this;
        },
        complete: function (XMLHttpRequest, textStatus) {
            this;
        }
    });
}

/*
*  方法: Array.remove(index)
*  功能: 删除数组元素.
*  参数: index删除元素的下标.
*  返回: 在原数组上修改数组.
*/
Array.prototype.remove = function (index) {
    if (isNaN(index) || index > this.length) { return false; }
    this.splice(index, 1);
}

/*克隆函数，传入要克隆的对象*/
var objClone = function (orgin) {
    var obj = {};
    if (typeof orgin == "object") {
        var cb = arguments.callee;
        if (orgin instanceof Array) {
            for (var i = 0, obj = [], l = orgin.length; i < l; i++) {
                obj.push(cb(orgin[i]));
            }
            return obj;
        }
        for (var i in orgin) {
            obj[i] = cb(orgin[i]);
        }
        return obj;
    }
    return orgin;
}